﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace DevExpress.MailClient.Win.Controls.Search
{
    public partial class ucSimpleSearchPanel : PRO_DOCS.BLL.WIN.Templates.DevxPermissionUserControlTemplate
    {
        public ucSimpleSearchPanel()
        {
            InitializeComponent();
        }

        public List<PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENT_FILE> GET_SEARCH_REULTS()
        {
            List<PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENT_FILE> aRCHIVE_DEPARTMENT_FILES = new List<PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENT_FILE>();
            DataSet dsResult = new PRO_DOCS.DAL.AppCode.SearchResults().GET_SIMPLE_SEARCH_RESULTS(txtSearchingKeyword.Text,
                chkDocumentBarcode.Checked,
                chkDocumentName.Checked,
                chkFolderName.Checked,
                chkDocumentExtension.Checked,
                chkDocumentIndex.Checked,
                chkDocumentNotes.Checked,
                chkDocumentType.Checked,
                chkOcrResults.Checked,
               PRO_DOCS.BLL.WIN.Authentication.LOGGED_IN_EMPLOYEE_ARCHIVES_SECURITY.CURRENT_LOGGED_IN_USER_ALLOWED_SEARCH_FOLDERS
                );

            for (int i = 0; i < dsResult.Tables[0].Rows.Count; i++)
            {
                DataRow dtr = dsResult.Tables[0].Rows[i];
                PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENT_FILE aRCHIVE_DEPARTMENT_FILE = (from file in PRO_DOCSDatabaseDataContext.ARCHIVE_DEPARTMENT_FILEs
                                                                                         where file.ARCHIVE_DEPARTMENT_FILE_ID.Equals(Guid.Parse(dtr["ARCHIVE_DEPARTMENT_FILE_ID"].ToString()))
                                                                                         select file).FirstOrDefault();
                aRCHIVE_DEPARTMENT_FILES.Add(aRCHIVE_DEPARTMENT_FILE);
            }

            return aRCHIVE_DEPARTMENT_FILES;
        }
    }
}
